using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using FikriKibar.Entities.Concrete;

namespace FikriKibar.DataAccess.Mapping
{
    public class ContentTypeLanguageLineMapping : EntityTypeConfiguration<ContentTypeLanguageLine>
    {
        public ContentTypeLanguageLineMapping()
            : this("dbo")
        {
        }
 
        public ContentTypeLanguageLineMapping(string schema)
        {
            ToTable(schema + ".ContentTypeLanguageLine");
            HasKey(x => x.Id);

            Property(x => x.Id).HasColumnName("Id").IsRequired().HasColumnType("int").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            Property(x => x.ContentTypeId).HasColumnName("ContentTypeId").IsRequired().HasColumnType("int");
            Property(x => x.LanguageId).HasColumnName("LanguageId").IsRequired().HasColumnType("int");
            Property(x => x.ContentTypeName).HasColumnName("ContentTypeName").IsRequired().HasColumnType("nvarchar").HasMaxLength(255);
            Property(x => x.ContentTypeDescription).HasColumnName("ContentTypeDescription").IsOptional().HasColumnType("nvarchar").HasMaxLength(500);
            Property(x => x.CreateDate).HasColumnName("CreateDate").IsRequired().HasColumnType("datetime");
            Property(x => x.CreatedBy).HasColumnName("CreatedBy").IsRequired().HasColumnType("int");
            Property(x => x.UpdateDate).HasColumnName("UpdateDate").IsRequired().HasColumnType("datetime");
            Property(x => x.UpdatedBy).HasColumnName("UpdatedBy").IsRequired().HasColumnType("int");
            Property(x => x.PublishBeginDate).HasColumnName("PublishBeginDate").IsRequired().HasColumnType("datetime");
            Property(x => x.PublishEndDate).HasColumnName("PublishEndDate").IsRequired().HasColumnType("datetime");
            Property(x => x.DisplayOrder).HasColumnName("DisplayOrder").IsRequired().HasColumnType("int");
            Property(x => x.IsApproved).HasColumnName("IsApproved").IsRequired().HasColumnType("bit");

            HasRequired(a => a.ContentType).WithMany(b => b.ContentTypeLanguageLines).HasForeignKey(c => c.ContentTypeId);
            HasRequired(a => a.Language).WithMany(b => b.ContentTypeLanguageLines).HasForeignKey(c => c.LanguageId);
            HasRequired(a => a.User_CreatedBy).WithMany(b => b.ContentTypeLanguageLines_CreatedBy).HasForeignKey(c => c.CreatedBy);
            HasRequired(a => a.User_UpdatedBy).WithMany(b => b.ContentTypeLanguageLines_UpdatedBy).HasForeignKey(c => c.UpdatedBy);
        }
    }

}
